package com.xjoyt.pay.master.po;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xjoyt.pay.constants.DateConstant;
import com.xjoyt.pay.vo.PayType;

/**
 * 代理商分润
 * 
 * @author Administrator
 *
 */
@Entity
@Table(name = "t_distributor_profit")
public class DistributorProfit {

	@Id
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid2")
	@Column(name = "distributor_profit_id", length = 36)
	public String id;

	/**
	 * 订单
	 */
	@ManyToOne(targetEntity = Order.class, cascade = {})
	@JoinColumn(name = "order_id", foreignKey = @ForeignKey(name = "none"))
	public Order order;

	/**
	 * 代理商
	 */
	@ManyToOne(targetEntity = Distributor.class, cascade = {})
	@JoinColumn(name = "distributor_id", foreignKey = @ForeignKey(name = "none"))
	public Distributor distributor;

	/**
	 * 结算费率(%)
	 */
	@Column(name = "rate")
	public Double rate;

	/**
	 * 成本费率(%)
	 */
	@Column(name = "cost_rate")
	public Double costRate;

	/**
	 * 支付类型(如：微信，支付宝)
	 */
	@Column(name = "`type`", length = 20)
	@Enumerated(EnumType.STRING)
	public PayType type;

	/**
	 * 订单金额(分)
	 */
	@Column(name = "money")
	public Long money;

	/**
	 * 固定手续费(分)
	 */
	@Column(name = "poundage")
	public Long poundage;

	/**
	 * 固定成本手续费(分)
	 */
	@Column(name = "cost_poundage")
	public Long costPoundage;
	
	/**
	 * 上限手续费(分)
	 */
	@Column(name = "`limit`")
	public Long limit;
	
	/**
	 * 上限成本手续费(分)
	 */
	@Column(name = "cost_limit")
	public Long costLimit;

	/**
	 * 下限手续费(分)
	 */
	@Column(name = "minimum")
	public Long minimum;
	
	/**
	 * 下限成本手续费(分)
	 */
	@Column(name = "cost_minimum")
	public Long costMinimum;
	
	/**
	 * 日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "added_date")
	@JsonFormat(pattern = DateConstant.DATE_TIME_FORMAT_PATTERN, timezone = "GMT+8")
	public Date addedDate;
}
